﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="CadastroTarefas.aspx.cs" Inherits="Pos_Projeto.Protegido.CadastroTarefas" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>

            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                CellPadding="4" DataKeyNames="CodigoTarefa" DataSourceID="SqlDataSource1" 
                ForeColor="#333333" GridLines="None">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:CommandField ButtonType="Button" SelectText="&gt;&gt;&gt;&gt;" 
                        ShowSelectButton="True" />
                    <asp:BoundField DataField="CodigoTarefa" HeaderText="CodigoTarefa" 
                        InsertVisible="False" ReadOnly="True" SortExpression="CodigoTarefa" />
                    <asp:BoundField DataField="CodigoProjeto" HeaderText="CodigoProjeto" 
                        SortExpression="CodigoProjeto" />
                    <asp:BoundField DataField="CodigoIteracao" HeaderText="CodigoIteracao" 
                        SortExpression="CodigoIteracao" />
                    <asp:BoundField DataField="NomeTarefa" HeaderText="NomeTarefa" 
                        SortExpression="NomeTarefa" />
                    <asp:BoundField DataField="TipoTarefa" HeaderText="TipoTarefa" 
                        SortExpression="TipoTarefa" />
                    <asp:BoundField DataField="HorasPrevistas" HeaderText="HorasPrevistas" 
                        SortExpression="HorasPrevistas" />
                    <asp:BoundField DataField="ValorNegocio" HeaderText="ValorNegocio" 
                        SortExpression="ValorNegocio" />
                    <asp:BoundField DataField="SituacaoTarefa" HeaderText="SituacaoTarefa" 
                        SortExpression="SituacaoTarefa" />
                </Columns>
                <EditRowStyle BackColor="#7C6F57" />
                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#E3EAEB" />
                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#F8FAFA" />
                <SortedAscendingHeaderStyle BackColor="#246B61" />
                <SortedDescendingCellStyle BackColor="#D4DFE1" />
                <SortedDescendingHeaderStyle BackColor="#15524A" />
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConflictDetection="CompareAllValues" 
                ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
                DeleteCommand="DELETE FROM [Tarefas] WHERE [CodigoTarefa] = @original_CodigoTarefa AND [CodigoProjeto] = @original_CodigoProjeto AND [CodigoIteracao] = @original_CodigoIteracao AND [NomeTarefa] = @original_NomeTarefa AND [TipoTarefa] = @original_TipoTarefa AND [HorasPrevistas] = @original_HorasPrevistas AND [ValorNegocio] = @original_ValorNegocio AND [SituacaoTarefa] = @original_SituacaoTarefa" 
                InsertCommand="INSERT INTO [Tarefas] ([CodigoProjeto], [CodigoIteracao], [NomeTarefa], [TipoTarefa], [HorasPrevistas], [ValorNegocio], [SituacaoTarefa]) VALUES (@CodigoProjeto, @CodigoIteracao, @NomeTarefa, @TipoTarefa, @HorasPrevistas, @ValorNegocio, @SituacaoTarefa)" 
                OldValuesParameterFormatString="original_{0}" 
                SelectCommand="SELECT * FROM [Tarefas]" 
                UpdateCommand="UPDATE [Tarefas] SET [CodigoProjeto] = @CodigoProjeto, [CodigoIteracao] = @CodigoIteracao, [NomeTarefa] = @NomeTarefa, [TipoTarefa] = @TipoTarefa, [HorasPrevistas] = @HorasPrevistas, [ValorNegocio] = @ValorNegocio, [SituacaoTarefa] = @SituacaoTarefa WHERE [CodigoTarefa] = @original_CodigoTarefa AND [CodigoProjeto] = @original_CodigoProjeto AND [CodigoIteracao] = @original_CodigoIteracao AND [NomeTarefa] = @original_NomeTarefa AND [TipoTarefa] = @original_TipoTarefa AND [HorasPrevistas] = @original_HorasPrevistas AND [ValorNegocio] = @original_ValorNegocio AND [SituacaoTarefa] = @original_SituacaoTarefa">
                <DeleteParameters>
                    <asp:Parameter Name="original_CodigoTarefa" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_NomeTarefa" Type="String" />
                    <asp:Parameter Name="original_TipoTarefa" Type="String" />
                    <asp:Parameter Name="original_HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="original_ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="original_SituacaoTarefa" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="NomeTarefa" Type="String" />
                    <asp:Parameter Name="TipoTarefa" Type="String" />
                    <asp:Parameter Name="HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="SituacaoTarefa" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="NomeTarefa" Type="String" />
                    <asp:Parameter Name="TipoTarefa" Type="String" />
                    <asp:Parameter Name="HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="SituacaoTarefa" Type="String" />
                    <asp:Parameter Name="original_CodigoTarefa" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_NomeTarefa" Type="String" />
                    <asp:Parameter Name="original_TipoTarefa" Type="String" />
                    <asp:Parameter Name="original_HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="original_ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="original_SituacaoTarefa" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <asp:FormView ID="FormView1" runat="server" DataKeyNames="CodigoTarefa" 
                DataSourceID="SqlDataSource2" onitemdeleted="FormView1_ItemDeleted" 
                oniteminserted="FormView1_ItemInserted" 
                onitemupdated="FormView1_ItemUpdated" BackColor="White" BorderColor="#CCCCCC" 
                BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" 
                GridLines="Horizontal">
                <EditItemTemplate>
                    CodigoTarefa:
                    <asp:Label ID="CodigoTarefaLabel1" runat="server" 
                        Text='<%# Eval("CodigoTarefa") %>' />
                    <br />
                    CodigoProjeto:
                    <asp:TextBox ID="CodigoProjetoTextBox" runat="server" 
                        Text='<%# Bind("CodigoProjeto") %>' />
                    <br />
                    CodigoIteracao:
                    <asp:TextBox ID="CodigoIteracaoTextBox" runat="server" 
                        Text='<%# Bind("CodigoIteracao") %>' />
                    <br />
                    NomeTarefa:
                    <asp:TextBox ID="NomeTarefaTextBox" runat="server" 
                        Text='<%# Bind("NomeTarefa") %>' />
                    <br />
                    TipoTarefa:
                    <asp:TextBox ID="TipoTarefaTextBox" runat="server" 
                        Text='<%# Bind("TipoTarefa") %>' />
                    <br />
                    HorasPrevistas:
                    <asp:TextBox ID="HorasPrevistasTextBox" runat="server" 
                        Text='<%# Bind("HorasPrevistas") %>' />
                    <br />
                    ValorNegocio:
                    <asp:TextBox ID="ValorNegocioTextBox" runat="server" 
                        Text='<%# Bind("ValorNegocio") %>' />
                    <br />
                    SituacaoTarefa:
                    <asp:TextBox ID="SituacaoTarefaTextBox" runat="server" 
                        Text='<%# Bind("SituacaoTarefa") %>' />
                    <br />
                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Editar" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
                </EditItemTemplate>
                <EditRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
                <EmptyDataTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandName="New">Novo</asp:LinkButton>
                </EmptyDataTemplate>
                <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
                <InsertItemTemplate>
                    CodigoProjeto:
                    <asp:TextBox ID="CodigoProjetoTextBox" runat="server" 
                        Text='<%# Bind("CodigoProjeto") %>' />
                    <br />
                    CodigoIteracao:
                    <asp:TextBox ID="CodigoIteracaoTextBox" runat="server" 
                        Text='<%# Bind("CodigoIteracao") %>' />
                    <br />
                    NomeTarefa:
                    <asp:TextBox ID="NomeTarefaTextBox" runat="server" 
                        Text='<%# Bind("NomeTarefa") %>' />
                    <br />
                    TipoTarefa:
                    <asp:TextBox ID="TipoTarefaTextBox" runat="server" 
                        Text='<%# Bind("TipoTarefa") %>' />
                    <br />
                    HorasPrevistas:
                    <asp:TextBox ID="HorasPrevistasTextBox" runat="server" 
                        Text='<%# Bind("HorasPrevistas") %>' />
                    <br />
                    ValorNegocio:
                    <asp:TextBox ID="ValorNegocioTextBox" runat="server" 
                        Text='<%# Bind("ValorNegocio") %>' />
                    <br />
                    SituacaoTarefa:
                    <asp:TextBox ID="SituacaoTarefaTextBox" runat="server" 
                        Text='<%# Bind("SituacaoTarefa") %>' />
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                        CommandName="Insert" Text="Insert" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </InsertItemTemplate>
                <ItemTemplate>
                    CodigoTarefa:
                    <asp:Label ID="CodigoTarefaLabel" runat="server" 
                        Text='<%# Eval("CodigoTarefa") %>' />
                    <br />
                    CodigoProjeto:
                    <asp:Label ID="CodigoProjetoLabel" runat="server" 
                        Text='<%# Bind("CodigoProjeto") %>' />
                    <br />
                    CodigoIteracao:
                    <asp:Label ID="CodigoIteracaoLabel" runat="server" 
                        Text='<%# Bind("CodigoIteracao") %>' />
                    <br />
                    NomeTarefa:
                    <asp:Label ID="NomeTarefaLabel" runat="server" 
                        Text='<%# Bind("NomeTarefa") %>' />
                    <br />
                    TipoTarefa:
                    <asp:Label ID="TipoTarefaLabel" runat="server" 
                        Text='<%# Bind("TipoTarefa") %>' />
                    <br />
                    HorasPrevistas:
                    <asp:Label ID="HorasPrevistasLabel" runat="server" 
                        Text='<%# Bind("HorasPrevistas") %>' />
                    <br />
                    ValorNegocio:
                    <asp:Label ID="ValorNegocioLabel" runat="server" 
                        Text='<%# Bind("ValorNegocio") %>' />
                    <br />
                    SituacaoTarefa:
                    <asp:Label ID="SituacaoTarefaLabel" runat="server" 
                        Text='<%# Bind("SituacaoTarefa") %>' />
                    <br />
                    <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Editar" />
                    &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Delete" />
                    &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                        CommandName="New" Text="Novo" />
                </ItemTemplate>
                <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
            </asp:FormView>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConflictDetection="CompareAllValues" 
                ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
                DeleteCommand="DELETE FROM [Tarefas] WHERE [CodigoTarefa] = @original_CodigoTarefa AND [CodigoProjeto] = @original_CodigoProjeto AND [CodigoIteracao] = @original_CodigoIteracao AND [NomeTarefa] = @original_NomeTarefa AND [TipoTarefa] = @original_TipoTarefa AND [HorasPrevistas] = @original_HorasPrevistas AND [ValorNegocio] = @original_ValorNegocio AND [SituacaoTarefa] = @original_SituacaoTarefa" 
                InsertCommand="INSERT INTO [Tarefas] ([CodigoProjeto], [CodigoIteracao], [NomeTarefa], [TipoTarefa], [HorasPrevistas], [ValorNegocio], [SituacaoTarefa]) VALUES (@CodigoProjeto, @CodigoIteracao, @NomeTarefa, @TipoTarefa, @HorasPrevistas, @ValorNegocio, @SituacaoTarefa)" 
                OldValuesParameterFormatString="original_{0}" 
                SelectCommand="SELECT * FROM [Tarefas] WHERE ([CodigoTarefa] = @CodigoTarefa)" 
                UpdateCommand="UPDATE [Tarefas] SET [CodigoProjeto] = @CodigoProjeto, [CodigoIteracao] = @CodigoIteracao, [NomeTarefa] = @NomeTarefa, [TipoTarefa] = @TipoTarefa, [HorasPrevistas] = @HorasPrevistas, [ValorNegocio] = @ValorNegocio, [SituacaoTarefa] = @SituacaoTarefa WHERE [CodigoTarefa] = @original_CodigoTarefa AND [CodigoProjeto] = @original_CodigoProjeto AND [CodigoIteracao] = @original_CodigoIteracao AND [NomeTarefa] = @original_NomeTarefa AND [TipoTarefa] = @original_TipoTarefa AND [HorasPrevistas] = @original_HorasPrevistas AND [ValorNegocio] = @original_ValorNegocio AND [SituacaoTarefa] = @original_SituacaoTarefa">
                <DeleteParameters>
                    <asp:Parameter Name="original_CodigoTarefa" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_NomeTarefa" Type="String" />
                    <asp:Parameter Name="original_TipoTarefa" Type="String" />
                    <asp:Parameter Name="original_HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="original_ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="original_SituacaoTarefa" Type="String" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="NomeTarefa" Type="String" />
                    <asp:Parameter Name="TipoTarefa" Type="String" />
                    <asp:Parameter Name="HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="SituacaoTarefa" Type="String" />
                </InsertParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView1" Name="CodigoTarefa" 
                        PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="NomeTarefa" Type="String" />
                    <asp:Parameter Name="TipoTarefa" Type="String" />
                    <asp:Parameter Name="HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="SituacaoTarefa" Type="String" />
                    <asp:Parameter Name="original_CodigoTarefa" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_NomeTarefa" Type="String" />
                    <asp:Parameter Name="original_TipoTarefa" Type="String" />
                    <asp:Parameter Name="original_HorasPrevistas" Type="Decimal" />
                    <asp:Parameter Name="original_ValorNegocio" Type="Int64" />
                    <asp:Parameter Name="original_SituacaoTarefa" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>

        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
